package com.wish.g04.system.controller;

import com.wish.g04.system.note.NoteConfig;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Random;

/**
 * 这个类的作者是123
 * 开发的日期是：2022/05/25
 **/

@RestController
@RequestMapping("message")
public class MessageController {

    @RequestMapping("sendTextMessage")
    public void sendTextMessage(String telephoneNumber){

        System.err.println(telephoneNumber);
        //生成4位数字验证码
        Random random = new Random();
        String code = "";
        for (int i = 0; i <4 ; i++) {
            code+=random.nextInt(10);
        }
        HashMap<String,Object> map = new HashMap<>();
        map.put("telephoneNumber",telephoneNumber);
        map.put("code",code);
        //调用发送短信
        try {
            NoteConfig.sendTextMessage(map);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
